package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.service.AppTokenService;
import com.ruoyi.shop.domain.Stores;
import com.ruoyi.shop.service.IStoresService;
import com.ruoyi.storeImage.domain.Storecoverimages;
import com.ruoyi.storeImage.service.IStorecoverimagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/app/shop")
public class AppShopController extends BaseController {
    @Autowired
    private IStoresService storesService;
    @Autowired
    private AppTokenService appTokenService;

    @Resource
    private IStorecoverimagesService storecoverimagesService;

    @GetMapping(value = "/{tag_name}")
    public AjaxResult getListByTag(@PathVariable("tag_name") String tag_name){
        List<Stores> storesList;
        storesList = storesService.getListByTag(tag_name);
        return AjaxResult.success(storesList);
    }
    /**
     * 获取店家管理详细信息
     */
    @PutMapping(value = "/{storeId}")
    public AjaxResult getInfo(@PathVariable("storeId") Long storeId)
    {
        return success(storesService.selectStoresByStoreId(storeId));
    }
    @GetMapping("/all")
    public AjaxResult getAllList(){
        List<Stores> storesList;
        storesList = storesService.getAllList();
        return AjaxResult.success(storesList);
    }
    /**
     * 获取店家图片的接口
     */
    @PutMapping("/images/{storeId}")
    public AjaxResult getImagesInfo(@PathVariable("storeId") long storeId)
    {
        List<Storecoverimages> storecoverimages = storecoverimagesService.selectImagesByStoreId(storeId);
        return AjaxResult.success(storecoverimages);
    }
}
